#!/bin/bash

IP=$(ip addr | grep 'inet' | grep -v inet6 | grep -vE '127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -o -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1)
if [[ "$IP" = "" ]]; then
  IP=$(wget -qO- ipv4.icanhazip.com)
fi

clear
clear
echo -e "\033[0;34m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\033[0m"
echo -e "\033[01;37m Capturador de IP                     \033[1;31m[\033[1;32m by 0ny-J \033[1;31m]"
echo -e "\033[0;34m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\033[0m"
echo -ne "\033[1;33mConfirme seu IP \033[1;37m"; read -e -i $IP ipdovps
echo "$ipdovps" >/etc/IP
echo "$ipdovps" >/etc/MEUIPADM
echo ""
echo -e "\033[1;32m IP Capturada \033[1;37m"
echo ""
echo -e "\033[0;34m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\033[0m"
echo -e "\033[1;33m Ruta guardada \033[1;31m/etc/IP \033[1;37m"
echo -e "\033[1;33m Ruta guardada \033[1;31m/etc/MEUIPADM \033[1;37m"
echo -e "\033[0;34m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\033[0m"
echo ""
echo -ne "Deseja Prosseguir a Menu? [S/N]: "; read x
[[ $x = @(n|N) ]] && exit
menu
